package com.java.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.java.pojo.entity.BorrowerAttach;
import com.java.mapper.BorrowerAttachMapper;
import com.java.pojo.vo.BorrowerAttachVo;
import com.java.service.BorrowerAttachService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 借款人上传资源表 服务实现类
 * </p>
 *
 * @author Helen
 * @since 2021-07-08
 */
@Service
public class BorrowerAttachServiceImpl extends ServiceImpl<BorrowerAttachMapper, BorrowerAttach> implements BorrowerAttachService {

    @Resource
    private BorrowerAttachMapper borrowerAttachMapper;

    //根据borrwer_id查询borrowerAttach
    @Override
    public List<BorrowerAttachVo> getBorrowerAttachList(Long id) {

        QueryWrapper<BorrowerAttach> wrapper = new QueryWrapper<>();
        wrapper.eq("borrower_id",id);
        List<BorrowerAttach> borrowerAttaches = borrowerAttachMapper.selectList(wrapper);
        List<BorrowerAttachVo> list = new ArrayList<>();
        borrowerAttaches.forEach(item->{
            BorrowerAttachVo borrowerAttachVo = new BorrowerAttachVo();
            BeanUtils.copyProperties(item,borrowerAttachVo);
            list.add(borrowerAttachVo);
        });
        return list;
    }
}
